<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"><meta name="format-detection" content="telephone=no">
    <title>charts-pie-customTooltips</title>
    <link rel="stylesheet" href="../plugin/seedsui/seedsui.min.css">
    <style>
        #canvas-holder {
            width: 100%;
            margin-top: 50px;
            text-align: center;
        }
        #chartjs-tooltip {
            opacity: 1;
            position: absolute;
            background: rgba(0, 0, 0, .7);
            color: white;
            padding: 3px;
            border-radius: 3px;
            -webkit-transition: all .1s ease;
            transition: all .1s ease;
            pointer-events: none;
            -webkit-transform: translate(-50%, 0);
            transform: translate(-50%, 0);
        }
        #chartjs-tooltip.below {
            -webkit-transform: translate(-50%, 0);
            transform: translate(-50%, 0);
        }
        #chartjs-tooltip.below:before {
            border: solid;
            border-color: #111 transparent;
            border-color: rgba(0, 0, 0, .8) transparent;
            border-width: 0 8px 8px 8px;
            bottom: 1em;
            content: "";
            display: block;
            left: 50%;
            position: absolute;
            z-index: 99;
            -webkit-transform: translate(-50%, -100%);
            transform: translate(-50%, -100%);
        }
        #chartjs-tooltip.above {
            -webkit-transform: translate(-50%, -100%);
            transform: translate(-50%, -100%);
        }
        #chartjs-tooltip.above:before {
            border: solid;
            border-color: #111 transparent;
            border-color: rgba(0, 0, 0, .8) transparent;
            border-width: 8px 8px 0 8px;
            bottom: 1em;
            content: "";
            display: block;
            left: 50%;
            top: 100%;
            position: absolute;
            z-index: 99;
            -webkit-transform: translate(-50%, 0);
            transform: translate(-50%, 0);
        }
    </style>
</head>

<body>
    <section id="page_charts_pie_customTooltips" class="active">
    	<header>
    	  <div class="titlebar">
            <a href="javascript:back()">
                <i class="icon icon-arrowleft"></i>
            </a>
            <h1>饼图</h1>
          </div>
    	</header>
    	<article>
    	    <div id="canvas-holder">
    	        <canvas id="chart-area1" width="50" height="50" />
    	    </div>
    	    <div id="canvas-holder">
    	        <canvas id="chart-area2" width="300" height="300" />
    	    </div>
    	
    	    <div id="chartjs-tooltip"></div>
    	</article>
    </section>
    
    <script src="../plugin/jquery/jquery.min.js"></script>
    <script src="../plugin/seedsui/seedsui.min.js"></script>
    <!--Exmobi能力-->
    <script src="../plugin/exmobi/exmobi.js"></script>
    <!--禁止ios弹性-->
    <script src="../plugin/inobounce/inobounce.min.js"></script>
    <!--chartJs-->
    <script src="../plugin/charts/Chart.min.js"></script>
    <script>
    Chart.defaults.global.customTooltips = function(tooltip) {

    	// Tooltip Element
        var tooltipEl = $('#chartjs-tooltip');

        // Hide if no tooltip
        if (!tooltip) {
            tooltipEl.css({
                opacity: 0
            });
            return;
        }

        // Set caret Position
        tooltipEl.removeClass('above below');
        tooltipEl.addClass(tooltip.yAlign);

        // Set Text
        tooltipEl.html(tooltip.text);

        // Find Y Location on page
        var top;
        if (tooltip.yAlign == 'above') {
            top = tooltip.y - tooltip.caretHeight - tooltip.caretPadding;
        } else {
            top = tooltip.y + tooltip.caretHeight + tooltip.caretPadding;
        }

        // Display, position, and set styles for font
        tooltipEl.css({
            opacity: 1,
            left: tooltip.chart.canvas.offsetLeft + tooltip.x + 'px',
            top: tooltip.chart.canvas.offsetTop + top + 'px',
            fontFamily: tooltip.fontFamily,
            fontSize: tooltip.fontSize,
            fontStyle: tooltip.fontStyle,
        });
    };

    var pieData = [{
        value: 300,
        color: "#F7464A",
        highlight: "#FF5A5E",
        label: "Red"
    }, {
        value: 50,
        color: "#46BFBD",
        highlight: "#5AD3D1",
        label: "Green"
    }, {
        value: 100,
        color: "#FDB45C",
        highlight: "#FFC870",
        label: "Yellow"
    }, {
        value: 40,
        color: "#949FB1",
        highlight: "#A8B3C5",
        label: "Grey"
    }, {
        value: 120,
        color: "#4D5360",
        highlight: "#616774",
        label: "Dark Grey"
    }];

    window.onload = function() {
        var ctx1 = document.getElementById("chart-area1").getContext("2d");
        window.myPie = new Chart(ctx1).Pie(pieData);

        var ctx2 = document.getElementById("chart-area2").getContext("2d");
        window.myPie = new Chart(ctx2).Pie(pieData);
    };
    //定义exmobi返回
    function back(){history.go(-1);}
    </script>
</body>

</html>
